Ext.define('PJ.view.myPersonalFiles.ParticipateClassList', {
    extend: 'AM.default.DefaultList',
    alias: ['widget.myPersonalFilesClassList'],
    requires: ['AM.default.DefaultSearchForm',
               'AM.default.DateTime', 
               'AM.default.DefaultDateField',
               'AM.default.DefaultDoubleDateField',
               'AM.default.jsonp.DefaultLoadJsonp',//jsonp加载数据
		       'AM.default.DefaultActiveStateCombo'
               ],
               selModel: {
               },
               initComponent: function(){
                  	var me= this;
                  	this.columns = [{
	                    header: '培训班名称',
	                    dataIndex: 't.className',
	                    flex: 1,
	                    minWidth: 120,
                  		renderer: function(value, metaData, record){
                  			metaData.style = "white-space:normal;cursor: pointer;color:blue;";
                  			metaData.tdAttr = "data-qtip='" + value + "' classId=" + record.get("classId");
                  			return value;
                  		},
                  		listeners: {
                  			click: function(g, clm){
                  				var classId = clm.getAttribute("classId");
                  				win = Ext.create('PJ.view.myPersonalFiles.LookPxarchives', {
                  					title: "查看培训班",
                  					flag:4,
                  					grid: me,
                  					isDisable:false,
                  					isReadOnly:true,
                  					classId:classId,
                  					isHideExpectTime: false
                  				}).show();
                  				var actionName = "load";
                  				if(gj_onlineLearning_constant.loadType == "jsonp"){
                  					actionName = "loadJsonp";
                  				}
                  				win.down("form").getForm().doAction(actionName,{
                  					url:me.store.preUpdateUrl,
                  					params:{
                  						classId: classId
                  					},
                  				});
                  			}
                  		}
                      },{
                          header: '主办单位',
                          dataIndex: 't.sponsorName',
                          width: 180,
                  		  renderer: function(value, metaData, record){
                  			metaData.tdAttr = 'data-qtip="' + value + '"';
                  			return value;
                  		  }
                      },{
                          header: '开班时间',
                          dataIndex: 't.beginDate',
                          width: 90 
                      },{
                          header: '结业时间',
                          dataIndex: 't.endDate',
                          width: 90 
                      },{
                          header: '班级学时',   
                          dataIndex: 't.trainingHour',
//                          sortable: false,
                          width: 65,
                          renderer: function(value, metaData, record){
                          	return value /*+ '/' + record.get('classUserNum')*/;
                          }
                      }];
                  	
                      this.store = Ext.create('PJ.'+ prototype +'.myPersonalFiles.ParticipateClassList',{
                      	isLoad: false
                      });
                      this.callParent(arguments);
                      this.loadType = gj_onlineLearning_constant.loadType;//加载方式
                  },
                  //发送
              	onAddMsgClick:function(){
                      var me = this;
                      var record=me.getSelectionModel().getSelection();
                  	var classId = record[0].get("classId");
                  	var className = record[0].get("t.className");
              		if(this.getSelectionModel().getCount() > 1){
                          Ext.Msg.show({
                              title: '提示',
                              msg: '操作时只可选中一条记录！',
                              icon: Ext.Msg.WARNING,
                              buttons: Ext.Msg.OK
                          });
                      	return;
                      }
              		win = Ext.create('PJ.view.messagemanagement.Edit', {
                      	title: "新增发送消息",
                      	width: 520,
                      	height:330,
                      	typeCode:1,
                      	classId:classId,
                      	flagStr:"class",
                      	grid: me
                      }).show();
              		win.down('panel').getForm().findField("defaultValue").setValue(className);
              		win.down('panel').getForm().findField("newsTypeCode").setValue("xxlx_pxb");
                  },
              	//新增
              	onAddClick:function(){
                      var me = this;
                      var classValue="";
                      Ext.Ajax.request({
                          url: 'module/trainingclass/preAddTraining2.json',
                          method: 'GET',
                          //async :  true,
                          success: function (response, options) {
                        	  
                              classValue=JSON.parse(response.responseText);
                              var selectScopeStr =classValue.sponsorName;
                              var selectScopeId=classValue.sponsorID;
//                              var classNum=classValue.classNum;
//                              var selectScopeStr = $(document.getElementById("selectScope")).find("option:selected").text();
//                              var selectScopeId=$(document.getElementById("selectScope")).find("option:selected")[0].value;
                              Ext.create('PJ.view.trainingmanagement.Add',{
                              	title: "新增培训班",
                                flag:1,
                              	grid: me,
                              	isDisable:true,
                              	isReadOnly:false,
                              	selectScopeStr:selectScopeStr,
                              	selectScopeId:selectScopeId,
//                              	classNum:classNum
                              });
                          },
                          failure: function (response, options) {
                              Ext.MessageBox.alert('失败', '请求超时或网络故障,错误编号：' + response.status);
                          }
                      });
                  },
              	//修改
              	onUpdateClick:function(){
              		var me = this;
              		var record=me.getSelectionModel().getSelection();
                  	var classId = record[0].get("classId");
              		if(this.getSelectionModel().getCount() > 1){
                          Ext.Msg.show({
                              title: '提示',
                              msg: '操作时只可选中一条记录！',
                              icon: Ext.Msg.WARNING,
                              buttons: Ext.Msg.OK
                          });
                      	return;
                      }
              		if(record[0].get("t.lockState")==1){
              			Ext.Msg.show({
                              title: '提示',
                              msg: '已审核的信息不允许再进行修改操作!',
                              icon: Ext.Msg.WARNING,
                              buttons: Ext.Msg.OK
                          });
                      	return;
              		}
                      win = Ext.create('PJ.view.trainingmanagement.Edit', {
                      	title: "更新培训班",
                          flag:2,
                      	grid: me,
                      	isDisable:true,
                      	classId:classId,
                      	isReadOnly:false
                      }).show();
              		var actionName = "load";
              		if(gj_onlineLearning_constant.loadType == "jsonp"){
              			actionName = "loadJsonp";
              		}
              		win.down("form").getForm().doAction(actionName,{
                  		url:me.store.preUpdateUrl,
                  		params:{
                  			classId: classId
                  		},
                  		success:function(f,action){
                  			var data = action.response.responseText;
                  			var json = gj_onlineLearning_constant.loadType=="ajax" ? Ext.decode(data, true) : action.response;
                  			var form = win.down('form');	 
                  			var baseForm = form.getForm();
                  			baseForm.findField("classNum").setValue(json.data.classNum);
                  			baseForm.findField("classNum_").setValue(json.data.classNum);
                  		}
                  	});
              	},
                  //配置课程
                  onConfigurationClick: function(button){
                  	var me = this;
                      var records = me.getSelectionModel().getSelection();
                      if (button.up("grid").getSelectionModel().getCount() > 1) {
                          Ext.Msg.show({
                              title: '警告',
                              msg: '操作时只可选中一条记录！',
                              icon: Ext.Msg.WARNING,
                              buttons: Ext.Msg.OK
                          });
                          return;
                      }else {
                      	win = Ext.create('PJ.view.trainingmanagement.ConfigurationCourseEdit',{
                          	title: "配置课程",
                          	grid: me,
                          	classId: records[0].get("classId")
                          }).show();
                  		var actionName = "load";//默认使用非JSONP的加载方法名“load”
                          if(gj_onlineLearning_constant.loadType=="jsonp") {
                          	actionName= "loadJsonp";
                          }
                          win.down('form').getForm().doAction(actionName,{
                          	url: me.store.preUpdateUrl,
                              params: {
                              	classId: records[0].get("classId")//培训班ID
                              },
                              success:function(form,action){
                              	var data = action.response.responseText;
                      			var json = gj_onlineLearning_constant.loadType=="ajax" ? Ext.decode(data, true) : action.response;
                      			var dateStar = json.data.beginDateStr;//举办时间（开始）
                      			var dateEnd = json.data.endDateStr;//举办时间（截止）
                      			var form = win.down('form');	 
                      			var baseForm = form.getForm();
                      			baseForm.findField("learnTime").setValue(dateStar + ' 至 ' + dateEnd);
                              }
                          });
                      }
                  },
                //报名
                  onSignupClick: function(){
                  	var me = this;
                      var records = me.getSelectionModel().getSelection();
                      if(records.length > 1){
                          Ext.Msg.show({
                              title: '提示',
                              msg: '只允许操作一条数据！',
                              icon: Ext.Msg.WARNING,
                              buttons: Ext.Msg.OK
                          });
                  		return;
                  	}
                      if(records[0].get("t.lockState") == 1){
                      	Ext.Msg.show({
                              title: '提示',
                              msg: '无法对已审核的班级进行报名！',
                              icon: Ext.Msg.WARNING,
                              buttons: Ext.Msg.OK
                          });
                          return;
                      }
                     var win = Ext.create('PJ.view.unitregistrationmanagement.SignUpFrame', {
              			grid: me,
              			title: "报名",
              			width: 1200,
              			height: 650,
              			classId: records[0].get("classId"),
              			openState: records[0].get("t.openState"),
              			publishState: records[0].get("t.publishState"),
              			signUpState:1,
              			auditingState:3,
              			clickSource:2
              		}).show();
              		var actionName = "load";
                      if(gj_onlineLearning_constant.loadType=="jsonp") {
                      	actionName= "loadJsonp";
                      }
                      win.down('form').getForm().doAction(actionName,{
                      	url: me.store.configurationUrl,
                          params: {
                          	classId: records[0].get("classId")//培训班ID
                          },
                          success:function(form,action){
                          	var data = action.response.responseText;
                  			var json = gj_onlineLearning_constant.loadType=="ajax" ? Ext.decode(data, true) : action.response;
                  			var dateStar = json.data.beginDateStr;//举办时间（开始）
                  			var dateEnd = json.data.endDateStr;//举办时间（截止）
                  			var form = win.down('form');	 
                  			var baseForm = form.getForm();
                  			baseForm.findField("className").setValue(json.data.className);//班级名称
                  			baseForm.findField("learnTime").setValue(dateStar + ' 至 ' + dateEnd);
                          }
                      });
                  },
              //查看报名通过人员
                onViewSignupStatus:function(){
                	var me = this;
                	var records = me.getSelectionModel().getSelection();
                	var auditingState=new Array();
            		auditingState.push(1);
            		auditingState.push(5);
                	win = Ext.create('PJ.view.registrationmanagement.ViewSignupStatusFrame',{
                		title: "查看审核通过人员",
                		grid: me,
                		classId:records[0].get("classId"),
                		className:records[0].get("t.className"),
//                		ministrieName:records[0].get("t.ministrieName"),查看报名
                		beginDate: records[0].get("t.beginDate"),
                		endDate: records[0].get("t.endDate"),
            			clickSource:1,
            			auditingState:auditingState,
                		openState: records[0].get("t.openState")
                	}).show();
                	var actionName = "load";//默认使用非JSONP的加载方法名“load”
                    if(gj_onlineLearning_constant.loadType=="jsonp") {
                    	actionName= "loadJsonp";
                    }
                    win.down('form').getForm().doAction(actionName,{
                    	url: me.store.configurationUrl,
                        params: {
                        	classId: records[0].get("classId")//培训班ID
                        },
                        success:function(form,action){
                        	var data = action.response.responseText;
                			var json = gj_onlineLearning_constant.loadType=="ajax" ? Ext.decode(data, true) : action.response;
                			var dateStar = json.data.beginDateStr;//举办时间（开始）
                			var dateEnd = json.data.endDateStr;//举办时间（截止）
                			var form = win.down('form');	 
                			var baseForm = form.getForm();
                			
                			baseForm.findField("className").setValue(json.data.className);//班级名称
//                			baseForm.findField("trainingDeptName").setValue(json.data.ministrieName);//委托部委
                			baseForm.findField("learnTime").setValue(dateStar + ' 至 ' + dateEnd);
                        }
                    });
                },
              	//删除
              	onDeleteClick:function(){
                	  var me = this;
                	  var store = me.getStore();
                	  var records = me.getSelectionModel().getSelection();
                	  for(var i=0;i<records.length;i++){
                		  if(records[i].get("t.publishState")==1){
                			Ext.Msg.show({
                				  title: '提示',
                			  	  msg  : '不允许删除已发布的数据！',
                			  	  icon :Ext.Msg.WARNING,
                			  	  buttons:Ext.Msg.OK
                			  });
                			  return;
                		  }
                	  };
                	Ext.Msg.confirm({
              		  title:'提示',
              		  msg:'您确定要删除这些数据吗?',
              		  icon:Ext.Msg.WARNING,
              		  buttons:Ext.Msg.OKCANCEL,
              		  fn:function(id){
              			  if(id=='ok'){
              				  var classIds= new Array();
              				  Ext.Array.each(records,function(name,index){
              					  classIds.push(name.get('classId'));
              				  });
              				  if(gj_onlineLearning_constant.loadType == "jsonp"){
              					  var store1 = Ext.create('AM.default.jsonp.DefaultAjaxStore',{
                                		loadType: gj_onlineLearning_constant.loadType,
                                        url: store.deleteUrl,
                                		  extraParams: {
                                			searchUpdateClassIds: classIds,
              							  submintType: 'activeStateToN'
                                        }
                                	});
                                	store1.load(function(rec, operation, success){
                                		if(success){
                                            Ext.Msg.alert('消息', '删除成功！', function(){
                                                var store = me.getStore();
                                                store.load();
                                            });
                                        }else{
                                            Ext.Msg.alert('消息', operation.error);
                                        }
                                	});
              				  }else{
              					  Ext.Ajax.request({
              						  url:store.deleteUrl,
              						  params: {
              							  searchUpdateClassIds: classIds,
              							  submintType: 'activeStateToN'
              	                       },
              						  success:function(response){
              							  var data=response.responseText;
              							  var json=Ext.decode(data,true);
              							  if(json.success){
              								  Orchid.alert('提示','删除成功!',function(){
              									  store.load();
              								  });
              							  }else{
              								  Orchid.alert('提示',json.msg);
              							  }
              						  }
              					  });
              				  }
              			  }
              		  }
              	  });
              	},
              	//发布
              	onIssueClick:function(){
                	  var me=this;
                	  var store=me.getStore();
                	  var records=me.getSelectionModel().getSelection();
                	  for(var i=0;i<records.length;i++){
                		  if(records[i].get("t.publishState")==1){
                			Ext.Msg.show({
                				  title: '提示',
                			  	  msg  : '已发布的班级不能再次发布!',
                			  	  icon :Ext.Msg.WARNING,
                			  	  buttons:Ext.Msg.OK
                			  });
                			  return;
                		  }
                		  if(records[i].get("t.lockState")==1){
                			Ext.Msg.show({
                				  title: '提示',
                			  	  msg  : '班级已审核不能再次进行操作!',
                			  	  icon :Ext.Msg.WARNING,
                			  	  buttons:Ext.Msg.OK
                			  });
                			  return;
                		  }
                		/*  if(records[i].get("auditState")!=1){
                			Ext.Msg.show({
              				  title: '提示',
              			  	  msg  : '只允许对审核通过的数据进行发布!',
              			  	  icon :Ext.Msg.WARNING,
              			  	  buttons:Ext.Msg.OK
              			  });
              			  return;
                		  }*/
                	  };
                	Ext.Msg.confirm({
              		  title:'提示',
              		  msg:'您确定要发布这些数据吗?',
              		  icon:Ext.Msg.WARNING,
              		  buttons:Ext.Msg.OKCANCEL,
              		  fn:function(id){
              			  if(id=='ok'){
              				  var classIds= new Array();
              				  Ext.Array.each(records,function(name,index){
              					  classIds.push(name.get('classId'));
              				  });
              				  
              				  if(gj_onlineLearning_constant.loadType == "jsonp"){
              					  var store1 = Ext.create('AM.default.jsonp.DefaultAjaxStore',{
                                		loadType: gj_onlineLearning_constant.loadType,
                                        url: store.issueUrl,
                                		  extraParams: {
                                			searchUpdateClassIds: classIds,
                                			submintType: 'publishStateToY'
                                        }
                                	});
                                	store1.load(function(rec, operation, success){
                                		if(success){
                                            Ext.Msg.alert('消息', '发布成功！', function(){
                                                var store = me.getStore();
                                                store.load();
                                            });
                                        }else{
                                            Ext.Msg.alert('消息', operation.error);
                                        }
                                	});
              				  }else{
              					  Ext.Ajax.request({
              						  url:store.issueUrl,
              						  params: {
              	                  			searchUpdateClassIds: classIds,
              	                  			submintType: 'publishStateToY'
              						  },
              						  success:function(response){
              							  var data=response.responseText;
              							  var json=Ext.decode(data,true);
              							  if(json.success){
              								  Orchid.alert('提示','发布成功!',function(){
              									  store.load();
              								  });
              							  }else{
              								  Orchid.alert('提示',json.msg);
              							  }
              						  }
              					  });
              				  }
              			  }
              		  }
              	  });
              	},
              	/**
              	 * 锁定班次
              	 */
              	onLockClass:function(){
              	  var me=this;
              	  var store=me.getStore();
              	  var records=me.getSelectionModel().getSelection();
              	  var isSponsror = false;
              	  for(var i=0;i<records.length;i++){
              		  if(records[i].get("t.lockState")==1){
              			Ext.Msg.show({
              				  title: '提示',
              			  	  msg  : '班级已审核不能再次进行操作!',
              			  	  icon :Ext.Msg.WARNING,
              			  	  buttons:Ext.Msg.OK
              			  });
              			  return;
              		  }
              		if(records[i].get("t.sponsorName") != "中共北京市委组织部" && records[i].get("t.sponsorName") != "中共中央组织部"){
              			isSponsror = true;
              		  }
              	  };
              	if(isSponsror){
              		Ext.Msg.confirm({
              		  title:'提示',
              		  msg:'本班次主办单位非“中共北京市委组织部”或“中共中央组织部”请确认是否核实完毕。',
              		  icon:Ext.Msg.WARNING,
              		  buttons:Ext.Msg.OKCANCEL,
              		  fn:function(id){
              			  if(id=='ok'){
              				  var classIds= new Array();
              				  Ext.Array.each(records,function(name,index){
              					  classIds.push(name.get('classId'));
              				  });
              				  
              				  if(gj_onlineLearning_constant.loadType == "jsonp"){
              					  var store1 = Ext.create('AM.default.jsonp.DefaultAjaxStore',{
                                		loadType: gj_onlineLearning_constant.loadType,
                                        url: store.updateClassLockState,
                                		  extraParams: {
                                			searchUpdateClassIds: classIds
                                        }
                                	});
                                	store1.load(function(rec, operation, success){
                                		if(success){
                                            Ext.Msg.alert('消息', '审核成功！', function(){
                                                var store = me.getStore();
                                                store.load();
                                            });
                                        }else{
                                            Ext.Msg.alert('消息', operation.error);
                                        }
                                	});
              				  }else{
              					  Ext.Ajax.request({
              						  url:store.updateClassLockState,
              						  params: {
              	                  			searchUpdateClassIds: classIds
              						  },
              						  success:function(response){
              							  var data=response.responseText;
              							  var json=Ext.decode(data,true);
              							  if(json.success){
              								  Orchid.alert('提示','审核成功!',function(){
              									  store.load();
              								  });
              							  }else{
              								  Orchid.alert('提示',json.msg);
              							  }
              						  }
              					  });
              				  }
              			  }
              		  }
              	  });
              	}else{
              		Ext.Msg.confirm({
              		  title:'提示',
              		  msg:'您确定要审核班级吗?',
              		  icon:Ext.Msg.WARNING,
              		  buttons:Ext.Msg.OKCANCEL,
              		  fn:function(id){
              			  if(id=='ok'){
              				  var classIds= new Array();
              				  Ext.Array.each(records,function(name,index){
              					  classIds.push(name.get('classId'));
              				  });
              				  
              				  if(gj_onlineLearning_constant.loadType == "jsonp"){
              					  var store1 = Ext.create('AM.default.jsonp.DefaultAjaxStore',{
                                		loadType: gj_onlineLearning_constant.loadType,
                                        url: store.updateClassLockState,
                                		  extraParams: {
                                			searchUpdateClassIds: classIds
                                        }
                                	});
                                	store1.load(function(rec, operation, success){
                                		if(success){
                                            Ext.Msg.alert('消息', '审核成功！', function(){
                                                var store = me.getStore();
                                                store.load();
                                            });
                                        }else{
                                            Ext.Msg.alert('消息', operation.error);
                                        }
                                	});
              				  }else{
              					  Ext.Ajax.request({
              						  url:store.updateClassLockState,
              						  params: {
              	                  			searchUpdateClassIds: classIds
              						  },
              						  success:function(response){
              							  var data=response.responseText;
              							  var json=Ext.decode(data,true);
              							  if(json.success){
              								  Orchid.alert('提示','审核成功!',function(){
              									  store.load();
              								  });
              							  }else{
              								  Orchid.alert('提示',json.msg);
              							  }
              						  }
              					  });
              				  }
              			  }
              		  }
              	  });
              	}
              	
            	},
            	/**
              	 * 导出xml
              	 */
                onExportClassUserXml:function(){
              	  var me=this;
              	  var store=me.getStore();
              	  var records=me.getSelectionModel().getSelection();
              	  for(var i=0;i<records.length;i++){
              		  if(records[i].get("t.lockState")==0){
              			Ext.Msg.show({
              				  title: '提示',
              			  	  msg  : '请先审核班级再进行导出!',
              			  	  icon :Ext.Msg.WARNING,
              			  	  buttons:Ext.Msg.OK
              			  });
              			  return;
              		  }
              	  };
              	for(var i=0;i<records.length;i++){
            		  if(records[i].get("shiguanNum")<=0){
            			Ext.Msg.show({
            				  title: '提示',
            			  	  msg  : '该班级没有市管学员!',
            			  	  icon :Ext.Msg.WARNING,
            			  	  buttons:Ext.Msg.OK
            			  });
            			  return;
            		  }
            	  };
              	Ext.Msg.confirm({
            		  title:'提示',
            		  msg:'您确定要导出xml吗?',
            		  icon:Ext.Msg.WARNING,
            		  buttons:Ext.Msg.OKCANCEL,
            		  fn:function(id){
            			  if(id=='ok'){
            				  var classIds= new Array();
            				  Ext.Array.each(records,function(name,index){
            					  classIds.push("'"+name.get('classId')+"'");
//            					  classIds.push(name.get('classId'));
            				  });
            				  href=store.exportClassUserXml + "?";
                          	  href+="searchUpdateClassIds=" + classIds;
                              href = encodeURI(href);
                              var atag = Ext.get("exportResume");
                              atag.set({
                                  "href": href
                              });
                              atag.dom.click();
            			  }
            		  }
            	  });
            	},
              	//撤销发布
              	onIssuenoClick:function(){
              		var me=this;
              		var store=me.getStore();
              		var records=me.getSelectionModel().getSelection();
              		for(var i=0;i<records.length;i++){
              			if(records[i].get("t.openState") ==3){
              				Ext.Msg.show({
              					title: '提示',
              					msg  : '不允许对已结班的数据执行撤销发布操作!',
              					icon :Ext.Msg.WARNING,
              					buttons:Ext.Msg.OK
              				});
              				return;
              			}
              			if(records[i].get("t.publishState")==2){
              				Ext.Msg.show({
              					title: '提示',
              					msg  : '不允许未发布的数据执行撤销发布操作!',
              					icon :Ext.Msg.WARNING,
              					buttons:Ext.Msg.OK
              				});
              				return;
              			}
              		};
              		Ext.Msg.confirm({
              			title:'提示',
              			msg:'您确定要撤销这些数据吗?',
              			icon:Ext.Msg.WARNING,
              			buttons:Ext.Msg.OKCANCEL,
              			fn:function(id){
              				if(id=='ok'){
              					var classIds= new Array();
              					Ext.Array.each(records,function(name,index){
              						classIds.push(name.get('classId'));
              					});
              					if(gj_onlineLearning_constant.loadType == "jsonp"){
              						var store1 = Ext.create('AM.default.jsonp.DefaultAjaxStore',{
              							loadType: gj_onlineLearning_constant.loadType,
              							url: store.noIssueUrl,
              							extraParams: {
              	                  			searchUpdateClassIds: classIds,
              	                  			submintType: 'publishStateToN'
              							}
              						});
              						store1.load(function(rec, operation, success){
              							if(success){
              								Ext.Msg.alert('消息', '撤销成功!', function(){
              									var store = me.getStore();
              									store.load();
              								});
              							}else{
              								Ext.Msg.alert('消息', operation.error);
              							}
              						});
              					}else{
              						Ext.Ajax.request({
              							url:store.noIssueUrl,
              							params: {
              	                  			searchUpdateClassIds: classIds,
              	                  			submintType: 'publishStateToN'
              							},
              							success:function(response){
              								var data=response.responseText;
              								var json=Ext.decode(data,true);
              								if(json.success){
              									Orchid.alert('提示','撤销成功!',function(){
              										store.load();
              									});
              								}else{
              									Orchid.alert('提示',json.msg);
              								}
              							}
              						});
              					}
              				}
              			}
              		});
              	},
              	//审核通过
              	onApprovalClick: function(){
              		var me=this;
              		var store=me.getStore();
              		var records=me.getSelectionModel().getSelection();
              		for(var i=0;i<records.length;i++){
              			if(records[i].get("auditState")==1){
              				Ext.Msg.show({
              					title: '提示',
              					msg  : '不允许审核通过的数据再次执行审核通过操作!',
              					icon :Ext.Msg.WARNING,
              					buttons:Ext.Msg.OK
              				});
              				return;
              			}
              			if(records[i].get("reportState")==2){
              				Ext.Msg.show({
              					title: '提示',
              					msg  : '不允许对未提交的数据执行审核通过操作!',
              					icon :Ext.Msg.WARNING,
              					buttons:Ext.Msg.OK
              				});
              				return;
              			}
              		};
              		Ext.Msg.confirm({
              			title:'提示',
              			msg:'您确定这些数据审核已通过吗?',
              			icon:Ext.Msg.WARNING,
              			buttons:Ext.Msg.OKCANCEL,
              			fn:function(id){
              				if(id=='ok'){
              					var classIds= new Array();
              					Ext.Array.each(records,function(name,index){
              						classIds.push(name.get('classId'));
              					});
              					if(gj_onlineLearning_constant.loadType == "jsonp"){
              						var store1 = Ext.create('AM.default.jsonp.DefaultAjaxStore',{
              							loadType: gj_onlineLearning_constant.loadType,
              							url: store.reuseUrl,
              							extraParams: {
              								searchUpdateClassIds: classIds,
              								submintType: 'auditClassStateToY'
              							}
              						});
              						store1.load(function(rec, operation, success){
              							if(success){
              								Ext.Msg.alert('消息', '审核成功!', function(){
              									var store = me.getStore();
              									store.load();
              								});
              							}else{
              								Ext.Msg.alert('消息', operation.error);
              							}
              						});
              					}else{
              						Ext.Ajax.request({
              							url:store.reuseUrl,
              							params: {
              								searchUpdateClassIds: classIds,
              								submintType: 'auditClassStateToY'
              							},
              							success:function(response){
              								var data=response.responseText;
              								var json=Ext.decode(data,true);
              								if(json.success){
              									Orchid.alert('提示','审核成功!',function(){
              										store.load();
              									});
              								}else{
              									Orchid.alert('提示',json.msg);
              								}
              							}
              						});
              					}
              				}
              			}
              		});
              	},
              	//审核驳回
              	onDismissedClick: function(){
              		var me=this;
              		var store=me.getStore();
              		var records=me.getSelectionModel().getSelection();
              		var classIds= new Array();
              		Ext.Array.each(records,function(name,index){
              			classIds.push(name.get('classId'));
              		});
              		for(var i=0;i<records.length;i++){
              			if(records[i].get("reportState")==2){
              				Ext.Msg.show({
              					title: '提示',
              					msg  : '不允许对未提交的数据执行审核通过操作!',
              					icon :Ext.Msg.WARNING,
              					buttons:Ext.Msg.OK
              				});
              				return;
              			}
              			if(records[i].get("auditState")==2){
              				Ext.Msg.show({
              					title: '提示',
              					msg  : '不允许对未审核通过的数据执行审核驳回操作!',
              					icon :Ext.Msg.WARNING,
              					buttons:Ext.Msg.OK
              				});
              				return;
              			}
              			if(records[i].get("t.publishState")==1){
              				Ext.Msg.show({
              					title: '提示',
              					msg  : '不允许对已发布的数据执行审核驳回操作！',
              					icon :Ext.Msg.WARNING,
              					buttons:Ext.Msg.OK
              				});
              				return;
              			}
              		};
              		Ext.create('PJ.view.trainingmanagement.CheckEdit',{
                      	title: "审核驳回原因",
                          flag:1,
                          classIds: classIds,
                      	grid: me
                      });
              	},
              	//上传参训通知
              	onImportClick: function(){
              		var me = this;
              		var records = me.getSelectionModel().getSelection();
              		if(records.length > 1){
              			Ext.Msg.show({
              				title: '提示',
              				msg: '只允许操作一条数据！',
              				icon: Ext.Msg.WARNING,
              				buttons: Ext.Msg.OK
              			});
              			return;
              		}
              		Ext.create("PJ.view.trainingmanagement.Upload", {
              			title: "上传参训通知",
              			height: 140,
              			width: 350,
              			grid: me,
              			classId: records[0].get('classId')
              		}).show();
//                  	Ext.create("PJ.view.trainingmanagement.UploadInfo", {
//              			title: "上传参训通知",
//              			height: 140,
//              			width: 350,
//              			grid: me,
//              			classId: records[0].get('classId')
//              		}).show();
                  },
                  //导出 -- 判断按钮是否可以操作
                  ifSelect: function(selectType, exportUrl, classId, urlExportId){
                  	var records = this.getSelectionModel().getSelection();
                  	if(selectType=='course'){
                  		if(records.length == 0){
                  			Ext.Msg.show({
                  				title: '提示',
                  				msg: '请选择一条数据进行操作！',
                  				icon: Ext.Msg.WARNING,
                  				buttons: Ext.Msg.OK
                  			});
                  			return;
                  		}
                  		if(records.length > 1){
                  			Ext.Msg.show({
                  				title: '提示',
                  				msg: '只允许操作一条数据！',
                  				icon: Ext.Msg.WARNING,
                  				buttons: Ext.Msg.OK
                  			});
                  			return;
                  		}
                  	}
                      var atag = Ext.get("exportResume");
                      var exportUrlStr = Ext.isEmpty(urlExportId)?exportUrl:exportUrl + '?'+ urlExportId + '=' + classId;
                  	atag.set({
                  		"href": exportUrlStr
                  	});
                      atag.dom.click();
                  
                  },
                /*//导入名额
                  onImportquotasClick: function(){
              		var me = this;
                  	Ext.create("PJ.view.quotamanagement.BatchImportEdit", {
              			title: "导入名额",
              			height: 110,
              			width: 380,
              			grid: me
              		}).show();
                  },*/
                  /**
                   * 计划名额
                   */
                  onPlanplacesClick: function(){
              		var me = this;
              		var record = this.getSelectionModel().getSelection();
                      if(this.getSelectionModel().getCount() > 1){
                          Ext.Msg.show({
                              title: '提示',
                              msg: '操作时只可选中一条记录！',
                              icon: Ext.Msg.WARNING,
                              buttons: Ext.Msg.OK
                          });
                      	return;
                      }
              		Ext.create('AM.default.DefaultWindowView', {
                          title: record[0].get("t.className"),
                          height:550,
                          width: 450,
                          grid: me,
                          classId:record[0].get("classId"),
                          items: [{
                              xtype: 'planPlacesList'
                          }],
                          listeners: {
                          	close: function(){
                          		me.getStore().load();
                          	}
                          }
                      });
              	},
              	onApplicationAuditClick:function(){
              		var me = this;
              		var record = this.getSelectionModel().getSelection();
	                if(this.getSelectionModel().getCount() > 1){
                      Ext.Msg.show({
                          title: '提示',
                          msg: '操作时只可选中一条记录！',
                          icon: Ext.Msg.WARNING,
                          buttons: Ext.Msg.OK
                      });
                  	 return;
	                }
                    var classId = record[0].get("classId");
      				var lockState = record[0].get("lockState");
      				var lockDateState = record[0].get("lockDateState");
      				 if(lockDateState==2){
                 			Ext.Msg.show({
                 				  title: '提示',
                 			  	  msg  : '本班级确认时间已过，请与管理员联系（63524157-8001）',
                 			  	  icon :Ext.Msg.WARNING,
                 			  	  buttons:Ext.Msg.OK
                 			  });
                 			  return;
                 		  }
                 		Ext.create('AM.default.DefaultWindowView', {
                             title: "培训学时确认",
                             height:510,
                             width: 1055,
                             grid: me,
                 			 clickSource:2,
                             classId: classId,
                             lockState: lockState,
                             items: [{
                                 xtype: 'applicationAuditUserListLevel1'
                             }],
                             listeners: {
                             	close: function(){
                             		me.getStore().load();
                             	}
                             }
                         });
              	},
              	/**
              	 * 导出培训班学习记录
              	 */
              	onExportClassRecordClick:function(){
              	  var me=this;
              	  var store=me.getStore();
              	  var records=me.getSelectionModel().getSelection();
              	  for(var i=0;i<records.length;i++){
              		  if(records[i].get("t.lockState")==0){
              			Ext.Msg.show({
              				  title: '提示',
              			  	  msg  : '请先审核班级再进行导出!',
              			  	  icon :Ext.Msg.WARNING,
              			  	  buttons:Ext.Msg.OK
              			  });
              			  return;
              		  }
              	  };
              	for(var i=0;i<records.length;i++){
            		  if(records[i].get("shiguanNum")<=0){
            			Ext.Msg.show({
            				  title: '提示',
            			  	  msg  : '该班级没有市管学员!',
            			  	  icon :Ext.Msg.WARNING,
            			  	  buttons:Ext.Msg.OK
            			  });
            			  return;
            		  }
            	  };
              	Ext.Msg.confirm({
            		  title:'提示',
            		  msg:'您确定要导出xml吗?',
            		  icon:Ext.Msg.WARNING,
            		  buttons:Ext.Msg.OKCANCEL,
            		  fn:function(id){
            			  if(id=='ok'){
            				  var classIds= new Array();
            				  Ext.Array.each(records,function(name,index){
            					  classIds.push("'"+name.get('classId')+"'");
//            					  classIds.push(name.get('classId'));
            				  });
            				  href=store.exportClassUserTotalXml + "?";
                          	  href+="searchUpdateClassIds=" + classIds;
                              href = encodeURI(href);
                              var atag = Ext.get("exportResume");
                              atag.set({
                                  "href": href
                              });
                              atag.dom.click();
            			  }
            		  }
            	  });
            	},
                  //预览
                  listeners: {
              		viewready: function(){
              			var me = this;
              			//导出按钮集合
                      	var exportMenu = Ext.create('Ext.menu.Menu', {
                              items: [{
                                  text: '培训班',
              	        		iconCls: 'classIco',
                                  listeners: {
                                      click: function(btn){
                                      	var records = me.getSelectionModel().getSelection();
                                      	//me.ifSelect('class', me.store.exportTrainingUrl);
                                      	
                                          var classIdstr = "";
                                          for(var i = 0;i<records.length;i++){
                                          	if(i == records.length-1){
                                          		classIdstr += "searchClassIdList=" + records[i].get("classId");
                                          	}else{
                                          		classIdstr += "searchClassIdList=" + records[i].get("classId") + "&";
                                          	}
                                          }
                                          var atag = Ext.get("exportResume");
                                          var exportUrl = me.store.exportTrainingUrl;
                                          atag.set({
                                              "href": exportUrl + '?' + classIdstr
                                          });
                                          atag.dom.click();
                                  	}
                                  }
                              }, {
                                  text: '课程',
              	        		iconCls: 'courseIco',
                                  listeners: {
                                  	click: function(btn){
                                      	var record = me.getSelectionModel().getSelection();
                                      	var classId = Ext.isEmpty(record) ? "" : record[0].get("classId");
                                      	me.ifSelect('course', me.store.exportCourseUrl, classId, 'searchClassId');
                                  	}
                                  }
                              }, {
                                  text: '班级详情',
              	        		iconCls: 'classDetailsIco',
                                  listeners: {
                                  	click: function(btn){
                                      	var records = me.getSelectionModel().getSelection();
                                          var classIds = new Array();
                                          Ext.Array.each(records, function(name, index){
                                          	classIds.push(name.get("classId"));
                                          });
                                      	if(records.length == 0){
                                  			Ext.Msg.show({
                                  				title: '提示',
                                  				msg: '请选择所需数据进行操作！',
                                  				icon: Ext.Msg.WARNING,
                                  				buttons: Ext.Msg.OK
                                  			});
                                  			return;
                                  		}else if(records.length > 1){
                                  			Ext.Msg.show({
                                  				title: '提示',
                                  				msg: '班级详情只可以选取一条数据！',
                                  				icon: Ext.Msg.WARNING,
                                  				buttons: Ext.Msg.OK
                                  			});
                                  			return;
                                  		}else{
                                  			var atag = Ext.get("exportResume");
                                              var exportUrl = me.store.exportClassInfoUrl;
                                              atag.set({
                                                  "href": exportUrl + '?searchClassIds=' + classIds
                                              });
                                              atag.dom.click();
                                  		}
                                  	}
                                  }
                              }/*, {
                                  text: '名额对比表',
              	        		iconCls: 'comparisonsIco',
                                  listeners: {
                                  	click: function(btn){
                                  		var records = me.getSelectionModel().getSelection();
                                      	//var classId = Ext.isEmpty(record) ? "" : record[0].get("classId");
                                      	//me.ifSelect('comparisons', me.store.contrastPlacesUrl, classId, 'searchClassId');
                                      	var classIdstr = "";
                                          for(var i = 0;i<records.length;i++){
                                          	if(i == records.length-1){
                                          		classIdstr += "searchClassIds=" + records[i].get("classId");
                                          	}else{
                                          		classIdstr += "searchClassIds=" + records[i].get("classId") + "&";
                                          	}
                                          }
                                          var atag = Ext.get("exportResume");
                                          var exportUrl = me.store.contrastPlacesUrl;
                                          atag.set({
                                              "href": exportUrl + '?' + classIdstr
                                          });
                                          atag.dom.click();
                                  	}
                                  }
                              }*/]
                          });
              			/*this.addDocked([{
              				dock: 'top',
              				xtype: "searchform",
              				columnCount: 3,
              				fieldDefaults: {
              					labelAlign: 'right',
              					labelWidth: 100
              				},
              				items: [{
              					xtype: "textfield",
              					fieldLabel: '培训班编号',
              					name: "searchTrainingNum",
              					maxLength: "50",
              					emptyText: "请输入培训班编号"
              				},{
              					xtype: "textfield",
              					fieldLabel: '培训班名称',
              					name: "searchClassName",
              					maxLength: "50",
                                emptyText: '请输入培训班名称，若多个班级请以“，”隔开'
              				},{
              					xtype: "textfield",
              					fieldLabel: '主办单位',
              					name: "searchSponsorName",
              					maxLength: "50",
              					emptyText: "请输入主办单位，若多个单位请以“，”隔开"
              				},{
              					xtype: "combo",
              					fieldLabel: '培训班类型',
              					name: "searchClassTypeCode",
              					store: Ext.create("Ext.data.ArrayStore", {
              						fields: ['value', 'text'],
              						data: [['ztb','专题班'],['zhutb','主体班'],['zhongydx','中组部调训'],['jwpx','境外培训'],['qit', '其他']]
              					}),
              					valueField: 'value',
              					displayField: 'text',
              					editable: false,
              					emptyText: "请选择"
              				},{
                  				xtype: 'defaultDate',
                  				fieldLabel: '开班时间',
                  				name: 'searchBeginDate',
                  				id: 'searchTrainingManagementSD',
                  				vtype: 'startLessEndDate',
                  				startLessEndDate: {
                  					targetCmpId: 'searchTrainingManagementED',
                  					isStart: true
                  				},
                  				emptyText: "请输入开班时间"
                  			}, {
                  				xtype: 'defaultDate',
                  				fieldLabel: '结业时间:',
                  				labelSeparator: '',
                  				name: 'searchEndDate',
                  				id: 'searchTrainingManagementED',
                  				vtype: 'startLessEndDate',
                  				vtypeText: '结束时间不能早于开始时间！',
                  				startLessEndDate: {
                  					targetCmpId: 'searchTrainingManagementSD',
                  					isStart: false
                  				},
                  				emptyText: "请输入结业时间"
                  			},{
              					xtype: "combo",
              					fieldLabel: '锁定状态',
              					name: "searchLockState",
              					store: Ext.create("Ext.data.ArrayStore", {
              						fields: ['value', 'text'],
              						data: [[1, '已锁定'],[0,'未锁定']]
              					}),
              					valueField: 'value',
              					displayField: 'text',
              					editable: false,
              					emptyText: "请选择"
              				},{
              					xtype: "combo",
              					fieldLabel: '开班年份',
              					name: "searchYear",
              					store: Ext.create("Ext.data.ArrayStore", {
              						fields: ['value', 'text'],
              						data: [[2017, '2017年'],[2016,'2016年'],[2015,'2015年'],[2014,'2014年'],[2013,'2013年'],[2012,'2012年']]
              					}),
              					valueField: 'value',
              					displayField: 'text',
              					editable: false,
              					emptyText: "请选择"
              				},{
              					xtype: "numberfield",
              					fieldLabel: '班级学时',
              					name: "searchTrainingHourMin",
              					minValue:1,
              					maxValue: 9999,
              					maxLength: "5",
              					emptyText: "请输入班级学时"
              				},{
              					xtype: "numberfield",
              					fieldLabel: '~',
              					name: "searchTrainingHourMax",
              					minValue:1,
              					maxValue: 9999,
              					maxLength: "5",
              					emptyText: "请输入班级学时"
              				}],
              				grid: this
              			},{
              				xtype: 'toolbar',
              				dock: 'top',
              				displayInfo: true,
              				items: [this.addButton, "-", this.updateButton, "-", 
              				{
                                text: '查看详情',
                                iconCls: 'applicationAuditIco',
                                itemId: this.oldId + "ApplicationAudit",
                                disabled: true,
                                scope: this,
                                handler: this.onApplicationAuditClick
                            },"-",{
	                        	  text: '导出',
	                              iconCls: 'deriveIco',
	                              itemId: this.oldId + "Export",
	                              disabled: false,
	                              scope: this,
	                              handler: this.onExportClassRecordClick
	                        },"->", this.countSelectPanel]
              			}]);*/
                      // 触发权限过滤事件
                      me.fireEvent("permission", this);
                      var params = me.store.proxy.extraParams;
                      Ext.apply(params, me.up('window').params,{searchYear:me.up('window').hourYear,searchClassType:me.up('window').searchClassType});
                      this.store.isLoad = true;
                      this.store.load();
              		}
                  }
              });
